package com.edushare.common.vo;

import java.util.ArrayList;
import java.util.List;

import com.edushare.common.constants.DefaultFiles;
import com.edushare.common.vo.FileDirectories.DIRECTORY_OWNER_TYPE;
import com.edushare.common.vo.auto._Departments;
import com.edushare.common.vo.interfaces.IFileUploadable;

public class Departments extends _Departments implements IFileUploadable,
		EduShareEntity, NameComparision {

	private static final long serialVersionUID = -6976826841469219344L;

	public Departments() {
		setSettings("zms:qd;zmv:qd;zcv:qd;zcc:qc;");
	}

	public ArrayList<Courses> getCourseListByOwnership(
			int courseDeptLinkTypeOwner) {
		ArrayList<Courses> cl = new ArrayList<Courses>();
		List<CourseDeptLink> cdll = getCourseLinks();
		for (CourseDeptLink cdl : cdll) {
			cl.add(cdl.getCourse());
		}
		return cl;
	}

	/** IFileuploadable implementations starts */
	public String getUploadedFileUrl() {
		if (getImageFile() == null) {
			return DefaultFiles.getDefaultImageFileUrl(this);
		}
		return getImageFile().getFileDownloadUrl();
	}

	public DIRECTORY_OWNER_TYPE getObjectType() {
		return DIRECTORY_OWNER_TYPE.DEPARTMENT;
	}

	public int getObjectPrimaryKey() {
		return getDepartmentId();
	}

	public String getTitle() {
		return getDeptName();
	}

	public String getName() {
		return getDeptName();
	}

	public int compareTo(INameComparable o) {
		return getName().compareTo(o.getName());
	}

	/** IFileuploadable implementations ends */

}
